<script>
import {defineComponent} from 'vue'

export default defineComponent({
    name: "mainBus",
    data() {
        return {
            // 默认数据
        }
    },
    props: {
        name: {
            type: String,
            default: ""
        },
        x1:{
            type: String,
            default: ""
        },
        y1:{
            type: String,
            default: ""
        },
        x2:{
            type: String,
            default: ""
        },
        y2:{
            type: String,
            default: ""
        },
        itemObj:{
            type: Object
        },
        data_id:{
            type: String,
            default: ''
        },
        stateDesc:{
            type: String,
            default: ""
        },
        isMainPage:{
            type: Boolean,
            default: false
        },
        color:{
            type: String,
            default: "rgb(128,0,128)"
        },
        jgName:{
            type: String,
            default: ""
        }
    },
    methods: {
        itemRightClick(event, currentItem,data_id,stateDesc,isMainPage,deviceName,type,jgName) {
            event.preventDefault(); // 阻止默认的右键菜单弹出
            // 显示自定义右键菜单
            const {clientX, clientY} = event
            let params = {
                clientX,
                clientY,
                data_id,
                type,
                jgName,
                stateDesc,
                isMainPage,
                deviceName,
                currentObj: {
                    name: currentItem?.deviceName,
                    jianGeMing: currentItem?.jiangeName,
                },

            }

            this.$emit('itemRightClick', params)
        },
    }
})

</script>

<template>
    <svg  @contextmenu.stop="itemRightClick($event,itemObj,data_id,stateDesc,isMainPage,name,'muxian')">
    <g style="cursor: pointer">
        <line :x1="x1" :y1="y1" :x2="x2" :y2="y2" :style="{stroke:color,strokeWidth:5}"/>
    </g>
    </svg>
</template>

<style scoped lang="less">

</style>
